package express.bttree;

/**
 * 作者：陈宏鸿
 * 功能：控制节点中的备选节点
 */
public class OrNode extends Node {
    public OrNode(){}

    @Override
    public State execute(Object target) {
        for (Node child : this.children) {
            State ok = child.execute(target);
            if(ok == State.Break) {
                return State.Break;
            }
            if(ok ==  State.True) {
                return State.True;
            }
        }
        return State.False;
    }

    @Override
    public String toString() {
        return "OrNode{" +
                "children=" + children +
                '}';
    }
}
